﻿<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <!--[if lt IE 9]
<script type="text/javascript" src="<%=basePath%>resources/lib/html5.js"></script>
<script type="text/javascript" src="<%=basePath%>resources/lib/respond.min.js"></script>
<script type="text/javascript" src="<%=basePath%>resources/lib/PIE_IE678.js"></script>
<![endif]-->
    <link rel="stylesheet" type="text/css" href="<%=basePath%>resources/static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="<%=basePath%>resources/static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="<%=basePath%>resources/lib/Hui-iconfont/1.0.7/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="<%=basePath%>resources/lib/icheck/icheck.css"/>
    <link rel="stylesheet" type="text/css" href="<%=basePath%>resources/static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="<%=basePath%>resources/lib/laypage/1.2/skin/laypage.css"/>
    <!--[if IE 6]>
    <script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>订单列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 游戏列表 <span
        class="c-gray en">&gt;</span> 订单列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
                                              href="javascript:location.replace(location.href);" title="刷新"><i
        class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <form action="<%=basePath%>order/orderList" method="get" class="form form-horizontal">
        <%--<input type="hidden" id="gameId" name="gameId" value="${object.gameId}"/>--%>
        <div class="text-c">
            价格:
            <input type="text" class="input-text" style="width:50px" placeholder="最低" name="priceMin" value="${object.priceMin}">
            -
            <input type="text" class="input-text" style="width:50px" placeholder="最高" name="priceMax" value="${object.priceMax}">
            日期：
            <input type="text" onfocus="WdatePicker()" id="datemin" name="datemin" value="${object.datemin}" class="input-text Wdate" style="width:160px;">
            -
            <input type="text" onfocus="WdatePicker()" id="datemax" name="datemax" value="${object.datemax}" class="input-text Wdate" style="width:160px;">
            游戏：
            <select id="gameSelect" name="gameId" class="select" style="width: 80px"></select>
            状态：
            <select id="orderTypeSelect" name="orderTypeSelect" class="select" style="width: 80px">
                <option id="-1" value="">所有状态</option>
                <c:if test="${userSession.type==1 ||userSession.type==2}">
                    <%--<option id="1" value="1" <c:if test="${object.orderTypeSelect==1}">selected='selected'</c:if> >订单过期</option>--%>
                    <option id="2" value="2" <c:if test="${object.orderTypeSelect==2}">selected='selected'</c:if> >等待接手</option>
                    <option id="3" value="3" <c:if test="${object.orderTypeSelect==3}">selected='selected'</c:if> >正在代练</option>
                    <option id="4" value="4" <c:if test="${object.orderTypeSelect==4}">selected='selected'</c:if> >等待验收</option>
                    <option id="5" value="5"<c:if test="${object.orderTypeSelect==5}">selected='selected'</c:if> >订单异常</option>
                    <option id="6" value="6" <c:if test="${object.orderTypeSelect==6}">selected='selected'</c:if> >已经结算</option>
                    <option id="7" value="7" <c:if test="${object.orderTypeSelect==7}">selected='selected'</c:if> >指定打手</option>
                    <option id="8" value="8"<c:if test="${object.orderTypeSelect==8}">selected='selected'</c:if> >等待结算</option>
                </c:if>
                <c:if test="${userSession.type==3}">
                    <option id="2" value="2"
                            <c:if test="${object.orderTypeSelect==2}">selected='selected'</c:if> >等待接手
                    </option>
                </c:if>
            </select>
            <input type="text" class="input-text" style="width:160px" placeholder="输入订单编号" name="orderId" value="${object.orderId}">
            <%--<input type="text" class="input-text" style="width:100px" placeholder="输入创建人id" name="userId" value="${object.userId}">--%>
            <button type="submit" class="btn btn-primary radius" name=""><i class="Hui-iconfont">&#xe665;</i> 搜订单
            </button>
        </div>
    </form>
    <%-- <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l"><a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>
            <a href="javascript:;" onclick="member_add('添加订单','<%=basePath%>order/orderAdd','','510')" class="btn btn-primary radius">
                <i class="Hui-iconfont">&#xe600;</i> 添加订单
            </a>
        </span>
        <span class="r">共有数据：<strong>${orders.size()}</strong> 条</span> </div>
    <div class="mt-20"> --%>
    <table class="table table-border table-bordered table-hover table-bg table-sort">
        <thead>
        <tr class="text-c">
            <%-- <th width="25"><input type="checkbox" name="" value=""></th> --%>
            <th width="50">订单编号</th>
            <c:if test="${userSession.type==1||userSession.type==2}">
                <th width="50">创建人</th>
            </c:if>
            <th width="30">游戏名称</th>
            <th width="60">区服</th>
            <c:if test="${object.gameName=='魔兽世界'}">
                <th width="35">阵营</th>
                <th width="35">职业天赋</th>
                <th width="35">装等</th>
            </c:if>
            <th width="150">代练内容</th>
            <c:if test="${userSession.type!=3}">
                <th width="20">订单价</th>
            </c:if>
            <th width="20">结算价</th>
            <th width="60">验收时间</th>
            <%--<th width="20">总时间</th>--%>
            <th width="50">状态</th>
            <th width="50">备注</th>
            <th width="50">操作</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${orders}" var="order">
            <tr class="text-c">
                    <%-- <td><input type="checkbox" value="${order.id}" name=""></td> --%>
                <td><u style="cursor:pointer" class="text-primary"
                       onclick="member_show('订单详情','<%=basePath%>/order/orderShow?id=${order.id}','10001','660','500')">${order.id}</u>
                </td>
                <c:if test="${userSession.type==1||userSession.type==2}">
                    <td><u style="cursor:pointer" class="text-primary"
                           onclick="member_show('用户详情','<%=basePath%>/user/memberShow?userId=${order.userId}','10001','660','500')">${order.userId}</u>
                    </td>
                </c:if>
                <td>${order.gameName}</td>
                <td>${order.serviceArea}</td>
                <c:if test="${object.gameName=='魔兽世界'}">
                    <td>${order.camp}</td>
                    <td>${order.professionalTalent}</td>
                    <td>${order.install}</td>
                </c:if>
                <td>${order.content}</td>
                <c:if test="${userSession.type!=3}">
                    <td>${order.orderPrice}</td>
                </c:if>
                <td>${order.settlePrice}</td>
                <td>${order.createTimeString}</td>
               <%--<td>${order.allTime}</td>--%>
                <td class="td-status">
                    <c:if test="${order.type==2||order.type==3||order.type==6}">
                        <span class="label label-success radius">${order.typeString}</span>
                    </c:if>
                    <c:if test="${order.type==1||order.type==4||order.type==7||order.type==8}">
                        <span class="label label-warning radius">${order.typeString}</span>
                    </c:if>
                    <c:if test="${order.type==5}">
                        <span class="label label-danger radius">${order.typeString}</span>
                    </c:if>
                </td>
                <td>${order.remark}</td>
                <td class="td-manage">
                    <c:if test="${userSession.type==3 && order.type==2}">
                        <a style="text-decoration:none" onClick="order_get(this,'${order.id}')" href="javascript:;"
                           title="申请"><i class="Hui-iconfont">&#xe603;</i></a>
                    </c:if>
                    <c:if test="${userSession.type == 1}">
                        <a title="删除" href="javascript:;" onclick="order_del(this,'${order.id}')" class="ml-5"
                           style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
                    </c:if>
                    <c:if test="${userSession.type == 1 || userSession.type == 2}">
                        <a title="编辑" data-title="修改订单" href="<%=basePath%>order/orderModify?orderId=${order.id}"
                           class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
                    </c:if>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>
</div>
<script type="text/javascript" src="<%=basePath%>resources/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="<%=basePath%>resources/lib/layer/2.1/layer.js"></script>
<script type="text/javascript" src="<%=basePath%>resources/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="<%=basePath%>resources/lib/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="<%=basePath%>resources/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="<%=basePath%>resources/static/h-ui/js/H-ui.js"></script>
<script type="text/javascript" src="<%=basePath%>resources/static/h-ui.admin/js/H-ui.admin.js"></script>
<script type="text/javascript">
    $(function () {
        $('.table-sort').dataTable({
            "aaSorting": [[8, "desc"]],//默认第几个排序
            "bStateSave": true,//状态保存
            "aoColumnDefs": [
                //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
                {"orderable": false, "aTargets": [1]}// 制定列不参与排序
            ]
        });
        $('.table-sort tbody').on('click', 'tr', function () {
            if ($(this).hasClass('selected')) {
                $(this).removeClass('selected');
            }
            else {
                table.$('tr.selected').removeClass('selected');
                $(this).addClass('selected');
            }
        });
        $.ajax({
            type: "get",
            url: "<%=basePath%>game/getGamesNoCount",
            async: false,
            cache: false,
            success: function (data) {
                $("#gameSelect").empty();
                $("#gameSelect").append("<option value='-1'>所有游戏</option>");
                for(var i =0;i<data.length;i++){
                    $("#gameSelect").append("<option value=" + data[i].id + ">" + data[i].name + "</option>");
                }
                $("#gameSelect").find("option[value='${object.gameId}']").attr("selected",true);
            }
        });
    });

    /*用户-添加*/
    function member_add(title, url, w, h) {
        layer_show(title, url, w, h);
    }
    /*用户-查看*/
    function member_show(title, url, id, w, h) {
        layer_show(title, url, w, h);
    }
    /*用户-停用*/
    function order_get(obj, id) {
        layer.confirm('确认要申请订单吗？', function (index) {
            $.ajax({
                url: "<%=basePath%>trade/addTrade",
                data: {"orderId": id},
                type: "post",
                cache: false,
                success: function (data) {
                    if (data.code == 0) {
                        layer.msg(data.message, {icon: 6, time: 2000});
                    } else {
                        layer.msg(data.message, {icon: 5, time: 2000});
                    }
                }
            });
        });
    }

    /*用户-启用*/
    function member_start(obj, id) {
        layer.confirm('确认要启用吗？', function (index) {
            $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="member_stop(this,id)" href="javascript:;" title="停用"><i class="Hui-iconfont">&#xe631;</i></a>');
            $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已启用</span>');
            $(obj).remove();
            layer.msg('已启用!', {icon: 6, time: 1000});
        });
    }
    /*用户-编辑*/
    function order_edit(title, url, id, w, h) {
        layer_show(title, url, w, h);
    }
    /*密码-修改*/
    function change_password(title, url, id, w, h) {
        layer_show(title, url, w, h);
    }
    /*用户-删除*/
    function order_del(obj, id) {
        layer.confirm('确认要删除吗？', function (index) {
            $.ajax({
                url: "<%=basePath%>order/deleteOrder",
                data: {"orderId": id, "orderType": 7},
                type: "post",
                cache: false,
                success: function (data) {
                    if (data.code == 0) {
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!', {icon: 1, time: 2000});
                    } else {
                        layer.msg(data.message, {icon: 5, time: 2000});
                    }
                }
            });
        });
    }
</script>
</body>
</html>